/*package com.clps.dev.sms.sm.dao.impl;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;

//import com.clps.dev.mms.common.util.encrypt.Encrypt;
//import com.clps.dev.mms.common.util.pagination.model.PageBean;

import com.clps.dev.sms.sm.dao.EmployeeDAO;
import com.clps.dev.sms.util.db.JDBCIMapper;
import com.clps.dev.sms.util.db.JDBCTemplate;
import com.clps.dev.sms.util.factory.DBFactory;

*//**
 * 
 * ClassName: EmployeeDAOImpl <br/>
 * Description: TODO ADD REASON(可选). <br/><br/>
 *
 * @author erwin.wang
 * @version V1.0
 * @since JDK 1.8
 * @2018年11月2日 上午11:34:45
 *//*
public class EmployeeDAOImpl<T> implements EmployeeDAO<T>{
	
	
	private static JDBCTemplate jdbctemplate;//连接数据库用的工具类
	private static ResultSet rs = null;//查询返回的结果集
	private static Connection connection ;//数据库连接对象
	private static PreparedStatement pst;//sql语句预编译通道
	private static List<Employee> list;
	private static CallableStatement cs;
    private static boolean flag = false; 
	private Object[] args ;
	private PageBean<UserInfo> myPageBean;//分页对象
	//private static PaginationDao<UserInfo> pagin;
	private static  Encrypt ec; //加密工具类	
	private String encpassword;//查询用户加密后的密码
	private static UserInfo user;
	
	//private 
	//private MyLog4J log = UtilFactory.getInstanceOfLog4J();
	
	
	static{	
		
		jdbctemplate = new JDBCTemplate();    	  
		list = new ArrayList<UserInfo>();
		pagin = PaginationFactory.getInstanceOfPagination();
	    user = new UserInfo();
	    ec = new Encrypt();
	}
		
    
    sql语句全部大写
     * sql名 eg:驼峰法，操作动作_操作哪个对象_sql
     * 模糊查询concat(?,'%')
     * update有错,不可以直接修改用户名和密码
     * 查询所有信息时，不需要查询所有字段
    
    //新增用户的 sql语句
    private static final String add_userinfo_sql = "INSERT INTO USERINFO"
    		              + "(USER_LOGON,USER_PASSWORD,USER_NAME,USER_GENDER,USER_MOBILE,"
    		              + "USER_EMAIL,USER_PHONE,USER_LEVEL,USER_DESCRITPION,USER_STATUS,"
    		              + "USER_BIRTH,USER_WEIXIN,USER_ICON,USER_CREATED_DATETIME,USER_CREATED_NAME,"
    		              + "USER_UPDATED_DATETIME,USER_UPDATED_NAME,USER_ROLE_ID) "
    		              + "VALUES (?,?,?,?,?,?,?,?,?,0,?,?,?,?,?,?,?,?)";
    //删除用户的 sql语句
    private static final String delete_userinfo_sql = "UPDATE USERINFO SET USER_STATUS = 2 WHERE USER_ID = ?";//逻辑删除
    
    //修改用户信息 的 sql语句                                        
    private static final String update_userinfo_sql = "UPDATE  USERINFO SET "
    													+"USER_NAME = ?,USER_GENDER = ?,"    //(不能直接修改  登录名和密码   "USER_LOGON = ?,USER_PASSWORD = ?,)
    													+ "USER_MOBILE = ?,USER_EMAIL = ?,USER_PHONE = ?,USER_LEVEL = ?,"
    													+ "USER_DESCRITPION = ?,USER_STATUS = ?,USER_BIRTH = ?,USER_WEIXIN = ?,"
    													+ "USER_ICON = ?,USER_CREATED_DATETIME = ?,USER_CREATED_NAME = ?,"
    													+ "USER_UPDATED_DATETIME = ?,USER_UPDATED_NAME = ?,USER_DEFAULT1 = ?,"
    													+ "USER_DEFAULT2 = ?,USER_ROLE_ID = ? WHERE USER_ID = ?";
    //查询用户信息 的  公用的  一段sql语句 
    private static final String select_userinfo_default_sql = "SELECT USER_ID,USER_NAME,USER_GENDER,USER_MOBILE,USER_EMAIL,USER_PHONE,USER_LEVEL,"
    		                                             + "USER_DESCRITPION,USER_STATUS, USER_BIRTH,USER_WEIXIN,USER_ICON,"
    		                                             + "USER_CREATED_DATETIME,USER_CREATED_NAME,USER_UPDATED_DATETIME,"
    		                                             + "USER_UPDATED_NAME ,USER_ROLE_ID ,ROLE_NAME FROM USERINFO ";
    
    //查询所有用户信息  的sql语句
    private static final String select_alluserinfo_sql = 	select_userinfo_default_sql+"LEFT JOIN ROLE ON USER_ROLE_ID = ROLE_ID WHERE USER_STATUS = 1";	                                                                                                   
    //通过id查询单个用户信息  的sql语句
    private static final String select_userinfo_sql = select_userinfo_default_sql +"LEFT JOIN ROLE ON USER_ROLE_ID = ROLE_ID "
    		                                                                      + "WHERE USER_STATUS = 1 AND USER_ID = ?";
                                                               
    //通过用户 user_name 模糊查询对应用户信息
    private static final String selectlike_userinfo_sql =  select_userinfo_default_sql +"LEFT JOIN ROLE ON USER_ROLE_ID = ROLE_ID "
                                                           + "WHERE USER_STATUS = 1 AND USER_NAME LIKE CONCAT(?,'%')";//模糊查询，sql的concat连接字符串方法
    
  
   //通过传入的角色名称  查询 对应的用户名称
    private static final String select_userinfo_by_roleid_sql = "SELECT USER_NAME FROM USERINFO WHERE USER_ROLE_ID = ?";
    		
    
    //通过    用户名和密码   查询用户信息  的sql语句         
    private static final String login_sql ="SELECT USER_LOGON  FROM USERINFO WHERE USER_STATUS = 0 AND "
                                            + "USER_LOGON  = ? AND USER_PASSWORD =?";
   
    //当角色不存在时，更新用户对应的角色id为null
    private static final String update_userInfo_role_sql = "UPDATE USERINFO SET USER_ROLE_ID = NULL "
    		                                               + "WHERE USER_ROLE_ID = ?";
    
    //激活用户
    private static final String active_userinfo_sql = "UPDATE USERINFO SET USER_STATUS = 1 "+
    		                                          "WHERE USER_LOGON = ? AND USER_PASSWORD = ?";
    
    *//**
     * 新增用户  addUserInfo
     * 
     * @param UserInfo 用户
     * 
     * @return boolean
     * 
     *//*
    
	@Override
	public boolean addUserInfo(UserInfo userinfo) {
		
		
		
		args = new Object[]{userinfo.getUser_logon(),userinfo.getUser_password(),userinfo.getUser_name(),userinfo.getUser_gender(),
               userinfo.getUser_mobile(),userinfo.getUser_email(),userinfo.getUser_phone(),userinfo.getUser_level(),userinfo.getUser_descritpion(),
               userinfo.getUser_birth(),userinfo.getUser_weixin(),userinfo.getUser_icon(),userinfo.getUser_created_datetime(),
               userinfo.getUser_created_name(),userinfo.getUser_updated_datetime(),userinfo.getUser_name(),userinfo.getUser_role_id(),userinfo.getUser_default1(),userinfo.getUser_default2()};
		System.out.println("**************************");
		System.out.println(userinfo.getUser_password());
		flag = jdbctemplate.updateData(add_userinfo_sql, args);
		return flag;
	}
	*//**
	 * 删除用户  deleteUserInfo
	 * @param UserInfo 用户
	 *
	 * 
	 * @return boolean
	 * 
	 *//*

	@Override
	public boolean deleteUserInfo(UserInfo userinfo) {
		
		args = new Object[]{userinfo.getUser_id()};
		flag = jdbctemplate.updateData(delete_userinfo_sql, args);
		return flag;
	}
   
	*//**
	 * 修改用户 updateUserInfo
	 * @param UserInfo 用户
	 * 
	 * @return boolean
	 * 
	 *//*
	@Override
	public boolean updateUserInfo(UserInfo userinfo) {		
		
		args = new Object[]{userinfo.getUser_name(),userinfo.getUser_gender(),
               userinfo.getUser_mobile(),userinfo.getUser_email(),userinfo.getUser_phone(),userinfo.getUser_level(),userinfo.getUser_descritpion(),
               userinfo.getUser_status(),userinfo.getUser_birth(),userinfo.getUser_weixin(),userinfo.getUser_icon(),userinfo.getUser_created_datetime(),
               userinfo.getUser_created_name(),userinfo.getUser_updated_datetime(),userinfo.getUser_updated_name(),userinfo.getUser_default1(),
               userinfo.getUser_default2(),userinfo.getUser_role_id(),userinfo.getUser_id()};
		flag = jdbctemplate.updateData(update_userinfo_sql, args);
		return flag;
	}
	
	
	*//**
	 * 查单一用户
	 * @param Integer 用户id
	 * 
	 * @return UserInfo
	 * 
	 *//*

	@Override
	public UserInfo getUserInfoById(Integer user_id) {
		System.out.println(user_id);
		
	    args = new Object[]{user_id};
	    JDBCIMapper map = new UserInfoMapperImpl();
	    log.info(select_userinfo_sql);
	    UserInfo userinfo = (UserInfo)jdbctemplate.queryUnique(select_userinfo_sql,map,args); 
	    		
		return userinfo;
								
	}

	*//**
	 * 查所有用户
	 * 
	 * @param int,int,int  当前页，总页数，总记录数
	 * @return List
	 * 
	 *//*
	@Override
	public List<UserInfo> queryAll(int currentPage, int pageSize,int totalRecord){		
		
	    myPageBean = new PageBean<UserInfo>(currentPage,pageSize,totalRecord);		
	    pagin.doQueryBySome(select_alluserinfo_sql, new Object[]{},new UserInfoMapperImpl<UserInfo>(),myPageBean);
		 return myPageBean.getDataList();
	}
	
	
	*//**
	 * 根据用户名模糊查询
	 * @param UserInfo
	 *
	 *@return UserInfo 
	 *//*

	@Override
	public UserInfo getUserInfoByName(UserInfo userinfo) {
		
	    args = new Object[]{userinfo.getUser_name()};
	    JDBCIMapper map = new UserInfoMapperImpl();
	    userinfo = (UserInfo)jdbctemplate.queryUnique(selectlike_userinfo_sql, map,args); 
	    		
		return userinfo;
	}
	
	*//**
	 * 登录
	 * 
     * 根据传入的username 和 password  语句查用户名
     * 
     * @param Object
     * @return List
     *//*
	public List<UserInfo> getPageByQuery(String user_logon, String password) throws Exception{
		
		    encpassword = ec.EncoderByMd5(password);
		 
			args = new Object[]{user_logon,encpassword};
	 try{
		try {
			// 获得连接
			connection = DBFactory.getConnection();
			// 创建会话
			pst = connection.prepareStatement(login_sql);
			for (int i = 0; i < args.length; i++) {
				pst.setObject(i + 1, args[i]);
			}
			rs = pst.executeQuery();
			if(rs.next()) {			
			UserInfo user = new UserInfo();	
			user.setUser_logon(rs.getString(1));
			list.add(user);			
			}
		} finally {
			DBFactory.close(cs, rs, pst, connection);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return list;
}
	
	 *//**
     * 
     * 根据传入 角色id 查 用户组
     * 
     * @param Object
     * 
     * @return  List
     *  
     *//*
	@Override
	public List<UserInfo> getUserInfoGroup(Object... args) throws Exception {
		try{
			try {
				// 获得连接
				connection = DBFactory.getConnection();
				// 创建会话
				pst = connection.prepareStatement(select_userinfo_by_roleid_sql);
				for (int i = 0; i < args.length; i++) {
					pst.setObject(i + 1, args[i]);
				}
				rs = pst.executeQuery();
				while(rs.next()) {			
				UserInfo user = new UserInfo();	
				user.setUser_name(rs.getString(1));	
				list.add(user);
				}

			} finally {
				DBFactory.close(cs, rs, pst, connection);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;

    }
	@Override
	public boolean updateUserInfoRole(Integer role_id) throws Exception {
		args = new Object[]{role_id};
		
		flag = jdbctemplate.updateData(update_userInfo_role_sql, args);
		
		return flag;
	}
	
	 *//**
     * 激活  用户
     * @param user_name  用户名
     * @return boolean
     *//*
	@Override
	public boolean updateUserInfoStatus(String user_name,String password) {
		args = new Object[]{user_name,password};
			flag = jdbctemplate.updateData(active_userinfo_sql, args);
			return flag;		
	}
}
*/